cmake_minimum_required(VERSION 3.4.1)

# 目标库名
set(LIB_NAME media)

find_library(log-lib log)
find_library(LIB-Z z)

# 根据abi导入头文件
# abiFilters "armeabi", "armeabi-v7a" , "arm64-v8a", "x86", "x86_64", "mips", "mips64"
include_directories(
        # 标准头文件
        ${ANDROID_NDK}/sysroot/usr/include
        ${CMAKE_SOURCE_DIR}/libs/jniLibs/${ANDROID_ABI}/ffmpeg/include
        ${CMAKE_SOURCE_DIR}/src/main/jni/include
)

# 导入FFmpeg库
add_library(libffmpeg SHARED IMPORTED)
set_target_properties(libffmpeg PROPERTIES
        IMPORTED_LOCATION ${CMAKE_SOURCE_DIR}/libs/jniLibs/${ANDROID_ABI}/libffmpeg.so)

# 添加本地代码
set(LOCAL_SRC src/main/jni)
add_library(
        ${LIB_NAME} SHARED
        ${LOCAL_SRC}/utils/codec_utils.c
        ${LOCAL_SRC}/encoder/video_encoder.c
        ${LOCAL_SRC}/jni_encoder.c
)
target_link_libraries(
        ${LIB_NAME}
        ${log-lib}
        ${LIB-Z}
        libffmpeg
)